package 游游的重组偶数;

import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int T = in.nextInt();
        while (T-- > 0) {
            char[] s = in.next().toCharArray();
            int n = s.length;
            int i = n - 1;
            for (i = n - 1; i >= 0; i--) {
                int num = s[i] - '0';
                if (num % 2 == 0) {
                    swap(s, i, n - 1);
                    System.out.println(new String(s));
                    break;
                }
            }
            if (i == -1) {
                System.out.println(-1);
            }
        }
    }

    private static void swap(char[] s, int i, int j) {
        char t = s[i];
        s[i] = s[j];
        s[j] = t;
    }
}
